package com.fafu.control;

import com.fafu.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import util.CookieUtils;
import util.Dictionary;
import util.JsonRsp;
import util.MyMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController()
@RequestMapping("/area")
@Api("区域相关")
public class AreaControl {
    @Autowired
    private AreaService areaService;

    private Logger logger = LoggerFactory.getLogger(AreaControl.class);
    @ApiOperation("获取区域列表")
    @RequestMapping(value = "/getArea",method = RequestMethod.GET)
    public JsonRsp getArea() {
        try{
            Map<String,Object> reMap = areaService.getAreas(new MyMap().toMap());
            return JsonRsp.success(reMap.get("data"));
        }catch(Exception e){
            logger.error(""+e);
            return JsonRsp.fail(Dictionary.CODE.SYSTEM_ERROR, "system error");
        }
    }

}
